<?php
namespace Model;
use Kuyuan\WqCore\Model\Model;
use Kuyuan\WqCore\util\Date;

class RedRecordModel extends Model
{
    protected $_fields = array(
        "id",
        "uniacid",
        "uid",
        "red_id",
        "money",
        "pid",
        "time",
        "to_go"
    );

    //---set----
    /**
     * 设置时间
     */
    public function setTimeAttr()
    {
        return TIMESTAMP;
    }

    //---get---

    /**
     * 获取时间
     * @param $_value
     * @return false|string
     */
    public function getTimeAttr($_value)
    {
        if($_value) {
            return Date::shortFormat($_value);
        }
    }

    /**
     * 获取用户信息
     * @param $_value
     * @param $_data
     * @return mixed
     */
    public function getUserAttr($_value,$_data)
    {
        if(isset($_data["uid"])) {
             return W7McMembersModel::where("uid",$_data["uid"])
                ->field(array("nickname","avatar"))
                ->cache(!KUYUAN_DEBUG)
                ->find();
        }
    }

}